%\documentclass[handout,18pt]{beamer}
\documentclass[18pt,xcolor=table]{beamer}
\usetheme{Madrid}

\usepackage{array}
\usepackage{graphics}
\usepackage{listings}
\usepackage{hyperref}
\usepackage[table]{xcolor}
\usepackage[absolute,overlay]{textpos}

\newcommand{\reference}[1]{
\begin{textblock*}{\textwidth}(2mm,90mm)
  \setlength{\fboxsep}{1pt}
  \tiny\colorbox{green!10!white}{\color{green!50!black}{#1}}
\end{textblock*}
}

\newcommand{\overlayicon}[1]{
\begin{textblock*}{3cm}(97mm,0.5mm)
  \hfill
  \includegraphics[height=9mm]{#1}
\end{textblock*}
}

\newcounter{savedenum}
\newcommand*{\saveenum}{\setcounter{savedenum}{\theenumi}}
\newcommand*{\resume}{\setcounter{enumi}{\thesavedenum}}

\definecolor{listcomment}{rgb}{0.0,0.0,1.0}
\definecolor{listkeyword}{rgb}{0.5,0.0,0.0}
\definecolor{listidentifier}{rgb}{0.0,0.3,0.0}
\definecolor{listdirective}{rgb}{0.5,0.0,1.0}
\definecolor{liststring}{rgb}{1.0,0.0,1.0}
\definecolor{listnumbers}{gray}{0.65}
\definecolor{listlightgray}{gray}{0.955}
\definecolor{listwhite}{gray}{1.0}
\definecolor{listbackground}{rgb}{0.95,0.95,1.0}
\definecolor{listbackground2}{rgb}{1.0,0.95,0.95}
\definecolor{listTitleMatlab}{rgb}{0.5,0.0,0.0}


\lstset{language=Python}
\lstset{numbers=none}
\lstset{frame=tb}
\lstset{xleftmargin=0.05\linewidth}
\lstset{backgroundcolor=\color{listbackground}}
\lstset{basicstyle=\tiny\ttfamily}
\lstset{keywordstyle=\color{listkeyword}\bfseries}
\lstset{identifierstyle=\color{listidentifier}}
\lstset{directivestyle=\color{listdirective}}
\lstset{commentstyle=\color{listcomment}}
\lstset{stringstyle=\ttfamily\color{liststring}}
\lstset{showstringspaces=false}
\lstset{escapeinside={(*@}{@*)}}
\lstset{morekeywords={as}}

\newcounter{ipycommand}
\newcommand{\pyprompt}{{\color{red}{\texttt{\textgreater\textgreater\textgreater}}}}
\newcommand{\pyreturn}{}
\newcommand{\ipyprompt}{\addtocounter{ipycommand}{1}{\color{blue}{\texttt{In [\arabic{ipycommand}]:}}}}
\newcommand{\ipyreturn}{{\color{red}{\texttt{Out[\arabic{ipycommand}]:}}}}

\newcommand{\lstlistingwithnumber}[3]{
\begin{center}
\lstset{numbers=left}
\lstset{xleftmargin=0.05\linewidth}
\lstinputlisting[linerange={#1-#2},firstnumber=#1,numbers=left]{#3}
\end{center}
}



\usepackage{verbatim}
\makeatletter
\newwrite\lstvrb@out
\newenvironment{matlabBlock}{%
\begingroup
\@bsphack
\immediate\openout\lstvrb@out\jobname.lst
\let\do\@makeother\dospecials\catcode`\^^M\active
\def\verbatim@processline{%
\immediate\write\lstvrb@out{\the\verbatim@line}}%
\verbatim@start}{%
\immediate\closeout\lstvrb@out
\@esphack
\endgroup
\begingroup
\setbeamercolor{block title}{bg=listTitleMatlab,fg=white}
\setbeamercolor{block body}{bg=listbackground2,fg=black}
\begin{block}{\tiny MATLAB}
\lstinputlisting[language=Matlab,numbers=none,
                 xleftmargin=0pt,xrightmargin=0pt,
                 aboveskip=1pt,belowskip=0pt,
                 backgroundcolor=\color{listbackground2},
                 frame=none]{\jobname.lst}
\end{block}
\endgroup}
\makeatother

\usepackage{verbatim}
\makeatletter
\newwrite\lstvrb@out
\newenvironment{pythonBlock}{%
\begingroup
\@bsphack
\immediate\openout\lstvrb@out\jobname.lst
\let\do\@makeother\dospecials\catcode`\^^M\active
\def\verbatim@processline{%
\immediate\write\lstvrb@out{\the\verbatim@line}}%
\verbatim@start}{%
\immediate\closeout\lstvrb@out
\@esphack
\endgroup
\begingroup
\setbeamercolor{block body}{bg=listbackground,fg=black}
\begin{block}{\tiny Python}
\lstinputlisting[language=Python,numbers=none,
                 xleftmargin=0pt,xrightmargin=0pt,
                 aboveskip=1pt,belowskip=0pt,
                 backgroundcolor=\color{listbackground},
                 frame=none]{\jobname.lst}
\end{block}
\endgroup}
\makeatother

\makeatletter
\lst@AddToHook{TextStyle}{\let\lst@basicstyle\ttfamily\fontfamily{pcr}\selectfont}
\makeatother
\newcommand{\lstmat}[1]{{\lstinline[language=matlab]{#1}}}
\newcommand{\lstpy}[1]{{\lstinline[language=python,morekeywords={as}]{#1}}}


\newcommand{\centeredlargetext}[3]{
{
\setbeamertemplate{navigation symbols}{}
\setbeamercolor{background canvas}{bg={#1}}
\color{#2}
\begin{frame}[plain]
\fontsize{36pt}{36pt}\selectfont
\center
\begin{center}
{#3}
\end{center}
\end{frame}
}}

\newcommand{\centeredhugetext}[3]{
{
\setbeamertemplate{navigation symbols}{}
\setbeamercolor{background canvas}{bg={#1}}
\fontsize{72pt}{72pt}\selectfont
\color{#2}
\begin{frame}[plain]
\center
\begin{center}
{#3}
\end{center}
\end{frame}
}}

\newcommand{\todo}[1]{{\color{red}{\textbf{#1}}}}


\begin{document}

\title{Python for MATLAB Users}
\subtitle{Promoting Open Source Computer Vision Research}
\institute[Kitware / Google]{Kitware, Inc. / Google Research}
\date[June 2012]{June 2012}

\section{Overview}

\begin{frame}
\titlepage
\begin{center}
\newcolumntype{C}{ >{\footnotesize\centering\arraybackslash} m{0.14\textwidth} }
\begin{tabular}{C@{}C@{}C@{}CC@{}C}
\includegraphics[height=2cm]{People/leotta} &
\includegraphics[height=2cm]{People/perera} &
\includegraphics[height=2cm]{People/reynolds} &
\includegraphics[height=2cm]{People/swears} &
\includegraphics[height=2cm]{People/zhao} &
\includegraphics[height=2cm]{People/ganapathi}  \\
Matt \linebreak Leotta &
Amitha \linebreak Perera &
Patrick \linebreak Reynolds &
Eran \linebreak Swears &
Yong \linebreak Zhao &
Varun \linebreak Ganapathi \\
%\cline{1-4} \cline{6-7}
\multicolumn{4}{c}{\includegraphics[height=0.5cm]{Logo/kitware}} &
\multicolumn{2}{c}{\includegraphics[height=0.5cm]{Logo/google}}  \\
\end{tabular}
\end{center}
\end{frame}


{
\setbeamertemplate{navigation symbols}{}
\begin{frame}[plain]
\center
\begin{center}
This presentation is copyrighted by\\
\textbf{Kitware, Inc.}\\
\bigskip
distributed under the\\
\textbf{Creative Commons by Attribution License 3.0}\\
\url{http://creativecommons.org/licenses/by/3.0}\\
\bigskip
Source code used in this presentation and\\
in accompanying examples and exercises\\
is distributed under the\\
\textbf{Apache License 2.0}\\
\url{http://www.apache.org/licenses/LICENSE-2.0}\\
\bigskip
Approved for Public Release, Distribution Unlimited
\end{center}
\end{frame}
}


%\begin{frame}
%  \tableofcontents
%\end{frame}


\begin{frame}
\frametitle{What this tutorial is about}
\begin{itemize}
\item Promote open source computer vision research.
  \begin{itemize}
  \item Reduce the community's dependence on MATLAB.
  \item Show MATLAB users how to migrate to Python.
  \item Present a Python IDE similar to that of MATLAB.
  \end{itemize}
\item Introduce Python for scientific computing.
\item Explain how to access functionality in Python from
      third party vision libraries (OpenCV, ITK).
\item Cover some advanced computing topics using Python:
  \begin{itemize}
  \item{parallel processing with threads}
  \item{GPU processing with PyCUDA and PyOpenCL}
  \item{calling C/C++ code from Python}
  \item{calling legacy MATLAB code from Python}
  \end{itemize}
\item Provided examples and hands-on exercises for all of the above.
\item Raffle of an ASUS Transformer Pad and more.
\end{itemize}
\end{frame}


\begin{frame}[fragile]
\frametitle{Schedule (Approximate)}
\begin{center}
  \begin{tabular}{ll}
     8:30  &  Overview, Virtual Machine Setup \\
     9:00  &  Intro to Python \\
    \hline
    \rowcolor[gray]{.95}
    10:00--10:30  &  Coffee Break \\
    \hline
    10:30  &  Python Scripting \\
    11:15  &  Scientific Python -- Numpy, Matplotlib, SciPy \\
    \hline
    \rowcolor[gray]{.95}
    12:30--1:30  &  Lunch \\
    \hline
     1:30  &  Using OpenCV \\
     2:15  &  Using Simple ITK \\
    \hline
    \rowcolor[gray]{.95}
     3:00--3:30  &  Coffee Break \\
    \hline
     3:30  &  Parallel Processing / GPU Processing \\
     4:15  &  Interfacing Python with C/C++ \\
     4:45  &  Interfacing Python with MATLAB \\
     5:00  &  Wrap-up, Raffle \\
  \end{tabular}
\end{center}
\end{frame}

\include{section-vm-distribution}
\include{section-open-source}
\include{section-vm-usage}
\include{section-python-intro}
\include{section-python-scripting}
\include{section-python-science}
\include{section-python-vision}
\include{section-python-parallel}
\include{section-python-interface}
\include{section-wrap-up}

\section{Appendix}
\centeredlargetext{white}{black}{Appendix}
\include{section-python-installation}

\end{document}
